<script setup>
const { data } = await getFetchData({
  url: "/portal/getActivityCategory",
  opts: {},
});
const router = useRouter();
const dataTypeList = ref([]);
const dataList = ref([]);
const selectCategoryName = ref("");
const activeIndex = ref(0);
const selectId = ref("");
dataTypeList.value = data.filter((item) => item.typeName == "重要活动");
handlechange(dataTypeList.value[0], 0);
async function handlechange(item, index) {
  selectCategoryName.value = item.typeName;
  activeIndex.value = index;
  selectId.value = item.id;
  let params = {
    pageNo: 1,
    pageSize: 999,
    categoryId: item.id,
  };
  const { data } = await getFetchData({
    url: "/portal/getActivityByCategoryId",
    opts: params,
  });
  dataList.value = data.list;
}
function goDetail(val) {
  router.push({
    path: `/activity/${val.id}`,
  });
}
</script>

<template>
  <Banner />
  <div class="dynamic-box mr-b-80">
    <div class="dynamic-left">
      <div class="dynamic-tit">同期活动</div>
      <div class="dynamic-sub">
        <div
          @click="handlechange(item, index)"
          :class="{ isActive: activeIndex == index }"
          v-for="(item, index) in dataTypeList"
        >
          {{ item.typeName }}
        </div>
      </div>
    </div>
    <div class="dynamic-center">
      <div class="dynamic-tit ac">{{ selectCategoryName }}</div>
      <div v-if="dataList.length">
        <div class="dynamic-list" v-for="(item, index) in dataList">
          <div>
            <img :src="item.activityCoverUrl" alt="" />
          </div>
          <div class="list-tit">{{ item.activityTitle }}</div>
          <div style="margin-bottom: 5px">
            <span v-if="item.startActivityTime" style="margin-right: 28px">{{
              item.startActivityTime
            }}</span
            ><span>{{ item.activityAddress }}</span>
          </div>
          <a @click.prevent="goDetail(item)"> 查看详情 </a>
        </div>
      </div>
      <div v-else style="text-align: center; margin-top: 50px; font-size: 20px">
        暂无数据!
      </div>
    </div>
  </div>
</template>
<style scoped>
body {
  background-color: #fff;
}
.dynamic-box {
  display: flex;
}

.dynamic-left {
  width: 28.125vw;
  margin-right: 5.417vw;
  text-align: right;
  color: #898989;
}

.dynamic-center {
  width: 30vw;
  margin-right: 3.177vw;
  margin-left: 16px;
}

.dynamic-tit {
  color: #101010;
  font-size: 1.458vw;
}

.ac {
  color: #ff6400;
  margin-bottom: 40px;
}

.dynamic-list {
  font-size: 0.729vw;
  color: #898989;
  margin-bottom: 25px;
}
.dynamic-list a {
  cursor: pointer;
  color: #ff6400;
}
.dynamic-list img {
  width: 100%;
  border-radius: 0.417vw;
  max-height: 15.365vw;
  object-fit: cover;
}

.time-tit {
  position: absolute;
  left: -16px;
  top: -26px;
  font-size: 20px;
  color: #ff6400;
  height: 29px;
  background-color: #fff;
  line-height: 29px;
}
.isActive {
  color: #ff6400;
}
.list-tit {
  font-size: 1.042vw;
  color: rgba(16, 16, 16);
  margin: 0.625vw 0 0.26vw 0;
}

.dynamic-left,
.dynamic-center {
  padding-top: 3.646vw;
}
.dynamic-sub {
  line-height: 2;
  margin-top: 13px;
}
.dynamic-sub div {
  cursor: pointer;
}
.dynamic-sub a {
  color: #898989;
}
@media (max-width: 768px) {
  .dynamic-box {
    display: block;
    padding: 0% 5%;
  }

  .dynamic-left,
  .dynamic-center {
    padding-top: 3.333vw;
    margin-left: 0;
  }

  .dynamic-left {
    width: 100%;
    text-align: left;
  }

  .dynamic-left div {
    margin-top: 1.733vw;
  }

  .dynamic-sub {
    display: flex;
    flex-wrap: wrap;
    line-height: 1;
  }

  .dynamic-sub > div {
    margin-right: 2.667vw;
  }

  .dynamic-center {
    width: 100%;
    margin-right: 0;
  }

  .dynamic-tit {
    font-size: 20px;
  }

  .dynamic-sub {
    font-size: 18px;
  }

  .dynamic-list {
    font-size: 16px;
    margin-top: 4vw;
  }

  .list-tit {
    font-size: 18px;
  }

  .time-tit {
    font-size: 18px;
  }
  .dynamic-list img {
    max-height: 45vw;
  }
}
</style>
